home *** CD-ROM | disk | FTP | other *** search
/ Day Cry / Day Cry CD.bin / oh_towns / tetujin / src.lzh / TETUSUB.C < prev   
Text File  |  1994-09-09  |  60KB  |  2,405 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <winb.h>
  5. #include <te.h>
  6. #include <fntb.h>
  7. #include <gui.h>
  8. #include <file_dlg.h>
  9. #include <wgb.h>
  10. #include <egb.h>
  11. #include <mos.h>
  12. #include <snd.h>
  13. #include <tifflib.h>
  14. #include <guidbg.h>
  15. #include "tetujin.h"
  16. #include "poly.h"
  17. #include "g_eff.h"
  18.  
  19. #undef    SHADE_SIZE    /* gui.hé┼é═2é╛é¬é▒é╠programé╔î└é┴é─ï¡ÉºôIé╔0 */
  20. #define SHADE_SIZE 0
  21. #define EFFECTCOUNT 10
  22.  
  23. /* abou */
  24. int    alertId = -1 ;
  25. int    messageId[4] = -1 ;
  26. int    dspIconId = -1 ;
  27. int    aboutOKBtnId = -1 ;
  28. int    aboutNumId = -1 ;
  29. /* desk */
  30. int    baseDialogId = -1 ;
  31. int    menubarId = -1 ;
  32. int    menuId = -1 ;
  33. int    mItemId[3] = -1 ;
  34. int    SDKmenuId = -1 ;
  35. int    SDKmItemId[3] = -1 ;
  36. int    fileMenuId = -1 ;
  37. int    fileMItemId[3] = -1 ;
  38. int    effectMenuId = -1 ;
  39. int    effectMItemId[EFFECTCOUNT] = -1 ;
  40. int    effectSpaceMItemId = -1 ;
  41. int    effectUndoMItemId = -1 ;
  42. int    quitIconId = -1 ;
  43. int    outIconId = -1 ;
  44. /* error */
  45. int    errorId = -1 ;
  46. int    errorOKBtnId = -1 ;
  47. int    errorIconId = -1 ;
  48. int    errormessage[2] = -1 ;
  49. /* set */
  50. int    baseSetupDialogId = -1 ;
  51. int    baseSetupDialogId2 = -1 ;
  52. int    baseSetupMesId[10] = -1 ;
  53. int    baseSetupModeTitleMesId = -1 ;
  54. int    baseSetupNumId[4] = -1 ;
  55. int    setupTIconId[6] = -1 ;
  56. int    setupAreaTIconId[3] = -1 ;
  57. int    baseSetupModeMesId[6] = -1 ;
  58. int    baseScrId[4] = -1 ;
  59. int    baseSDBtnId[2] = -1 ;
  60. int    baseSetupTitleMesId = -1 ;
  61. /* filesâIâvâVâçâôùp */
  62. int    fileSubDialogId = -1 ;
  63. int    fileBtnId[3] = -1 ;
  64. int    fileMesId[3] = -1 ;
  65. /* windowùpëeé╠æ╢ì▌ */
  66. int    windowId = -1 ;
  67. int    vscrollId = -1 ;
  68. int    hscrollId = -1 ;
  69.  
  70. /* Ä└æ╘(âüâCâôâ\ü[âXé╔é─ëeé⌐éτì∞éΦé╛é╖Ä└æ╘) */
  71. GRAPHWIN window[WINCOUNT] = -1 ;    /* windowÄ└æ╘kobj */
  72.  
  73. int boundWidth ;    /* ëíé╠ë≡æ£ôx(512/640) */
  74.  
  75. static int effectNum = -1 ;
  76. BASICSET effectSet[EFFECTCOUNT] = {
  77.                             { "ò╜èèë╗âtâBâïâ^",
  78.     
  79.                               3,
  80.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  81.                               "ï¡é│(0ü`100)", 80, 0, 100,
  82.                               "ù╓èsÉⁿò█æ╢(0ü`100)", 50, 0, 100,
  83.                               "", 0, 0, 100,
  84.  
  85.                               0,
  86.                               "",
  87.                               "",
  88.                               "",
  89.                               "",
  90.                               "",
  91.                               "",
  92.                               "",
  93.                               0,
  94.  
  95.                               0
  96.                             },
  97.  
  98.                             { "âVââü[âvâlâX",
  99.     
  100.                               3,
  101.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  102.                               "ï¡é│(0ü`100)", 80, 0, 100,
  103.                               "âmâCâYæjÄ~(0ü`100)", 50, 0, 100,
  104.                               "", 0, 0, 100,
  105.  
  106.                               0,
  107.                               "",
  108.                               "",
  109.                               "",
  110.                               "",
  111.                               "",
  112.                               "",
  113.                               "",
  114.                               0,
  115.  
  116.                               0
  117.                             },
  118.  
  119.                             { "âüâfâBâAâôüEâtâBâïâ^",
  120.     
  121.                               2,
  122.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  123.                               "ù╓èsÉⁿò█æ╢(0ü`100)", 30, 0, 100,
  124.                               "", 0, 0, 100,
  125.                               "", 0, 0, 100,
  126.  
  127.                               0,
  128.                               "",
  129.                               "",
  130.                               "",
  131.                               "",
  132.                               "",
  133.                               "",
  134.                               "",
  135.                               0,
  136.  
  137.                               0
  138.                             },
  139.  
  140.                             { "âfâWâ^âCâYüEâXâÇü[âT",
  141.     
  142.                               1,
  143.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  144.                               "", 0, 0, 100,
  145.                               "", 0, 0, 100,
  146.                               "", 0, 0, 100,
  147.  
  148.                               4,
  149.                               "âéü[âh",
  150.                               "è∩ÉöâëâCâô(Äπ)",
  151.                               "è∩ÉöâëâCâô(ï¡)",
  152.                               "ï⌠ÉöâëâCâô(Äπ)",
  153.                               "ï⌠ÉöâëâCâô(ï¡)",
  154.                               "",
  155.                               "",
  156.                               0,
  157.  
  158.                               0
  159.                             },
  160.  
  161.                             { "âtâ@âWâBüEâîâKü[âg",
  162.     
  163.                               2,
  164.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  165.                               "âZâôâTü[(0ü`100)", 88, 0, 100,
  166.                               "", 0, 0, 100,
  167.                               "", 0, 0, 100,
  168.  
  169.                               0,
  170.                               "",
  171.                               "",
  172.                               "",
  173.                               "",
  174.                               "",
  175.                               "",
  176.                               "",
  177.                               0,
  178.  
  179.                               0
  180.                             },
  181.  
  182.                             { "ïPôxâfü[â^é╠ò╜ÆRë╗(ùvÄ₧è╘)",
  183.     
  184.                               3,
  185.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  186.                               "ïPôxì┼żÆl(0ü`255)", 0, 0, 255,
  187.                               "ïPôxì┼æσÆl(0ü`255)", 255, 0, 255,
  188.                               "", 0, 0, 100,
  189.  
  190.                               2,
  191.                               "ïPôxö═ê═é╠É▌ÆΦò√û@",
  192.                               "ÄΦ  ô«",
  193.                               "Ä⌐  ô«",
  194.                               "",
  195.                               "",
  196.                               "",
  197.                               "",
  198.                               0,
  199.  
  200.                               0
  201.                             },
  202.  
  203.                             { "ÉFé╠ì─özÆu(ùvÆ╖Ä₧è╘)",
  204.     
  205.                               1,
  206.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  207.                               "", 0, 0, 100,
  208.                               "", 0, 0, 100,
  209.                               "", 0, 0, 100,
  210.  
  211.                               3,
  212.                               "âéü[âh",
  213.                               "ÉFé╠ì╠ÅW",
  214.                               "ÉFé╠ò╜ÆRì─özÆu",
  215.                               "ÉFé╠ÆPÅâì─özÆu",
  216.                               "",
  217.                               "",
  218.                               "",
  219.                               0,
  220.  
  221.                               0
  222.                             },
  223.  
  224.                             { "YUVò╧è╖ & î╕èKÆ▓",
  225.     
  226.                               4,
  227.                               "ì¼ìçöΣ(0ü`100)", 100, 0, 100,
  228.                               "ïPôx(Y) é╠èKÆ▓", 64, 0, 256,
  229.                               "ÉFæè(Cb)é╠èKÆ▓", 16, 0, 256,
  230.                               "ÉFæè(Cr)é╠èKÆ▓", 16, 0, 256,
  231.  
  232.                               4,
  233.                               "ÉFæèé╠é▄é╤é½",
  234.                               "é▄é╤é½é╚é╡",
  235.                               "ëíò√îⁿé▄é╤é½",
  236.                               "Åcò√îⁿé▄é╤é½",
  237.                               "Åc ëí é▄é╤é½",
  238.                               "",
  239.                               "",
  240.                               0,
  241.  
  242.                               0
  243.                             }
  244.                         } ;
  245.  
  246. char polygonBuffer[ 640*512/8 ] ;    /* â|âèâSâôÄwÆΦì∞ï╞ù╠êµ */
  247.  
  248. char tifPath[100] ;            /*  ô╟é▌ì₧é▌âpâXû╝ */
  249.  
  250. char *undoBuf = NULL ;        /*  âAâôâhâEâoâbâtâ@  */
  251. char *alphaBuf = NULL ;
  252. int  undoLot = 0 ;
  253.  
  254. int outMode = 0 ;        /*  0:normal display 1:ègæσ display */
  255.  
  256. static int actId ;            /*    é╟é╠âEâBâôâhâEé¬âAâNâeâBâué⌐é≡é╡é▀é╖ò╧Éö    */
  257. static int windowflg = 0 ;    /*    âEâBâôâhâEé¬ë╜ûçèJéóé─éóéΘé⌐é≡é╡é▀é╖ò╧Éö    */
  258. static int outLupx, outLupy ;    /*  ègæσÄ₧é╠ò\Īì╢Åπì└òW */
  259. static int saveMode = 0 ;        /*  save mode 0:1600û£ÉF 1:32768ÉF */
  260. static int saveCompMode = 0 ;    /*  save mode 0:normal, 1:comp. */
  261.  
  262. extern char    *guiEgbPtr ;            /*    EGB é╠âÅü[âNâAâhâîâX    */
  263.  
  264.  
  265.  
  266. /***** âGâtâFâNâgâRâ}âôâhÄ└ìsâïü[â`âô *****/
  267.  
  268. static execx, execy, execAreaMode ;        /* âèü[âh&âëâCâgè╓Éöùpé╠ò╧Éö */
  269. static char *execOutBuf ;
  270.  
  271. /* âAâôâhâDâoâbâtâ@é⌐éτé╠âèü[âhè╓Éö */
  272. static int execRead1( int x, int y, unsigned char *a )
  273. {
  274.     if( x < 0 )x = 0 ;
  275.     if( y < 0 )y = 0 ;
  276.     if( x >= execx )x = execx - 1 ;
  277.     if( y >= execy )y = execy - 1 ;
  278.  
  279.     DWORD( a ) = DWORD( undoBuf + (y*execx + x)*3 ) ;
  280.  
  281.     if( execAreaMode < 2 )
  282.         a[3] = getArea( x, y ) ;
  283.     else
  284.         a[3] = 1 ;
  285.  
  286.     return NOERR ;
  287. }
  288.  
  289. /* âAâEâgâvâbâgâoâbâtâ@é⌐éτé╠âèü[âhè╓Éö */
  290. static int execRead2( int x, int y, unsigned char *a )
  291. {
  292.     if( x < 0 )x = 0 ;
  293.     if( y < 0 )y = 0 ;
  294.     if( x >= execx )x = execx - 1 ;
  295.     if( y >= execy )y = execy - 1 ;
  296.  
  297.     DWORD( a ) = DWORD( execOutBuf + (y*execx + x)*3 ) ;
  298.  
  299.     if( execAreaMode < 2 )
  300.         a[3] = getArea( x, y ) ;
  301.     else
  302.         a[3] = 1 ;
  303.  
  304.     return NOERR ;
  305. }
  306.  
  307. /* âAâEâgâvâbâgâoâbâtâ@é╓é╠âëâCâgè╓Éö */
  308. static int execWrite( int x, int y, unsigned char *a )
  309. {
  310.     int d ;
  311.  
  312.     if( x < 0 )x = 0 ;
  313.     if( y < 0 )y = 0 ;
  314.     if( x >= execx )x = execx - 1 ;
  315.     if( y >= execy )y = execy - 1 ;
  316.  
  317.     d = (y*execx + x)*3 ;
  318.     WORD( execOutBuf + d ) = WORD( a ) ;
  319.     BYTE( execOutBuf + d + 2 ) = BYTE( a + 2 ) ;
  320.  
  321.     return NOERR ;
  322. }
  323.  
  324. /* â}âXâNâoâbâtâ@é⌐éτé╠âèü[âhè╓Éö */
  325. static int execMask( int x, int y )
  326. {
  327.     return 0 ;
  328. }
  329.  
  330. /* âGâtâFâNâgÄ└ìs */
  331. static int execEffect( FRAME areaFrame )
  332. {
  333.     int i, d[5] ;
  334.  
  335.     execOutBuf = window[actId].buf16m ;        /* âAâEâgâvâbâgâoâbâtâ@ */
  336.  
  337.     if( effectNum < 0 )return NOERR ;        /* effecté╠æIæ≡é¬é╚é│éΩé─é╚éó */
  338.     if( windowflg <= 0 )return NOERR ;        /* windowé¬èJé⌐éΩé─é╚éó */
  339.     if( execOutBuf == NULL )return NOERR ;    /* dataé¬é╚éó */
  340.     if( undoBuf == NULL )return NOERR ;        /* âAâôâhâDâoâbâtâ@é¬é╚éó */
  341.  
  342.     execx = window[actId].dx ;                /* èGé╠ëíò¥ */
  343.     execy = window[actId].dy ;                /* èGé╠Åcò¥ */
  344.     if( areaFrame.lupx < 0 )areaFrame.lupx = 0 ;    /* é═é▌é╛é╡é≡ÅCÉ│ */
  345.     if( areaFrame.lupy < 0 )areaFrame.lupy = 0 ;
  346.     if( areaFrame.rdwx > execx-1 )areaFrame.rdwx = execx-1 ;
  347.     if( areaFrame.rdwy > execy-1 )areaFrame.rdwy = execy-1 ;
  348.  
  349.     execAreaMode = effectSet[effectNum].areaMode ;
  350.                         /* âGâèâAÉ▌ÆΦâéü[âh(╬▀╪║▐▌,Älèpî`,æSæ╠é╠ïµò╩)é╠ÆèÅo */
  351.  
  352.     trans( window[actId].buf16m, undoBuf, execx*execy*3 ) ;    /* dataü¿undoBuf */
  353.     trans( window[actId].bufAlpha, alphaBuf, execx*execy ) ;
  354.  
  355.     for( i=0 ; i<4 ; i++ )                    /* É▌ÆΦÆlé╠ÆèÅo */
  356.         d[i] = effectSet[effectNum].set[i].prt ;
  357.     d[4] = effectSet[effectNum].mode ;
  358.  
  359.     switch( effectNum )                        /* âGâtâFâNâgè╓Éöé╠æIæ≡ */
  360.     {
  361.     case 0:
  362.         softnessFilter( areaFrame, d ) ;
  363.         break ;
  364.     case 1:
  365.         sharpnessFilter( areaFrame, d ) ;
  366.         break ;
  367.     case 2:
  368.         medianFilter( areaFrame, d ) ;
  369.         break ;
  370.     case 3:
  371.         digitizeSmooth( areaFrame, d ) ;
  372.         break ;
  373.     case 4:
  374.         fuzzy( areaFrame, d ) ;
  375.